<template>
  <div class="tixian_box">
    <ul class="tixian_ul geren_ul">
      <li class="tixian_li">
        <span>昵称</span>
        <input type="text" v-model="nicheng" />
      </li>
      <li class="tixian_li">
        <span>手机号码</span>
        <input type="number" v-model="shoujihao" placeholder="请填写手机号码" />
      </li>
      <li class="tixian_li">
        <span>真实姓名</span>
        <input type="text" v-model="xingming" placeholder="请填写真实姓名" />
      </li>
      <li class="tixian_li">
        <span>支付宝昵称</span>
        <input type="text" v-model="zhifubao" placeholder="请填写支付宝昵称" />
      </li>
      <li class="tixian_li">
        <span>微信昵称</span>
        <input type="text" v-model="weixin" placeholder="请填写微信昵称" />
      </li>
    </ul>
    <p class="yinhangka_p2">温馨提示：请准确填写基本信息，避免充值信息核对错误！</p>
    <button class="red_btn" @click="tijiao_btn">确认提交</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      nicheng: "", //昵称
      shoujihao: "", //请填写手机号码
      xingming: "", //真实姓名
      zhifubao: "", //请填写支付宝昵称
      weixin: "" //请填写微信昵称
    };
  },
  //   渲染之前
  created() {
	//   git提交
    this.http
      .get("/api/member/info")
      .then(res => {
        if (res.status_code == 200) {
          (this.shoujihao = res.data.phone),
            (this.xingming = res.data.truename),
            (this.zhifubao = res.data.alipay_nick),
            (this.weixin = res.data.wechat_nick),
            (this.nicheng = res.data.nickname);
        } else {
           this.$toast(res.message);
        }
      })
  },
  methods: {
    // 点击确认提交
    async tijiao_btn() {
      // 判断
      if (
        !this.nicheng ||
        !this.shoujihao ||
        !this.xingming ||
        !this.zhifubao ||
        !this.weixin
      ) {
          this.$toast("请输入完善信息");
        return;
      }
      //   对接口
      try {
        let res = await this.http.post("/api/update/minfo", {
          // 对字段
          phone: this.shoujihao,
          truename: this.xingming,
          alipay_nick: this.zhifubao,
          wechat_nick: this.weixin,
          nickname: this.nicheng
        });
        
        // 提交
        if (res.status_code === 200) {
          this.$toast(res.message);
          this.$router.back();
        } else {
          this.$toast(res.message);
        }
      } catch (error) {
        // this.$toasted.error(error.message,{icon:"error"}).goAway(2000);
      }
    }
  }
};
</script>

<style>
@import url("../../assets/css/ttcp/chongzhi.css");
.tixian_box {
  background-color: #f2f2f2;
  height: 100vh;
}
</style>